PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Specifying a File by File Specification

You can use a file specification to refer to a file that may not yet exist. The File Specification value class is described in File Specification. You can obtain a file specification from the New File scripting addition command distributed with AppleScript, or from an application command that returns a file specification.

You might use a file specification when you want to let a user specify a filename and location for a file that may not exist, but that you will create or save at a later time. For example, your script could use the first statement below to obtain a file specification by calling the New File scripting addition, which displays a standard system dialog to obtain a filename and location from the user. (The second statement just displays the class of the returned value.) In this case, the script supplies a default name of "New Report":

set fileSpec to new file default name "New Report"
class of fileSpec --result: file specification

Suppose your script has opened a new AppleWorks document named "Untitled 1" and stored that name in a variable called currentDocument . The document has not yet been saved to disk, but the script has executed the statement shown above to get a file specification for the file. At a later point, your script could use the following Tell statement to save the document:

tell application "AppleWorks"
    save document currentDocument in fileSpec
end tell
--result: "Untitled 1" renamed and saved as "New Report".

© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)